package cn.hzc.fortess.core.common.constant;

import cn.hzc.fortess.core.common.HttpContext;
import org.apache.commons.lang3.StringUtils;

public interface JwtConstants {

    String AUTH_HEADER = "Authorization";

    String SECRET = "defaultSecret";

    //N分钟
    Long EXPIRATION = (1000*60)*60*24L;

    String AUTH_PATH = "/authspi/auth2token";

    String BEARER = "Bearer ";

//    String JWT_COOKIE = "x-token-fortress";


    static String getJwtHeaderToken() {
        // --->Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNTY1Nzc1MTI3LCJpYXQiOjE1NjU3NzE1Mjd9.66WI8kTQf4RlyLAuYXbjHMSHNCx4YeMS0MH1fKo4XA2Ew3ikZN0AG2p3Ec2Z5yNRrebnOym37EMrQWsisjx48g
        String token = HttpContext.getRequest().getHeader(AUTH_HEADER);
        if (StringUtils.isBlank(token) || token.length() <= BEARER.length()) {
            return null;
        }
        return StringUtils.substringAfter(token, BEARER);
    }

}
